package com.example.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Devices;
import com.example.entity.Params;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DevicesMapper extends BaseMapper<Devices> {

    List<Devices> findBySearchOfDevices(@Param("params")Params params);

    @Select("select * from devices;")
    List<Devices> findAll();

    @Insert("insert into graduation.devices value (#{deviceId},#{deviceName},#{deviceType},#{status},#{controlMode},#{location},#{threshold})")
    void addDevice(Devices device);

    @Select("select device_name from graduation.devices where device_id = #{deviceId} limit 1")
    Devices findDeviceNameByDeviceId(@Param("deviceId") String deviceId);


    @MapKey("name")
    List<Map<String,Object>> initPie();
}
